package com.googlecode.likesql.converter;

import java.util.LinkedList;
import java.util.List;

import com.googlecode.likesql.constant.SqlConstant;
import com.googlecode.likesql.utils.StringUtils;

/**
 * @author Johny Huang
 *
 */
public class StringConverter implements Converter {

    public String toTemplate(Object obj) {
		return String.valueOf(SqlConstant.CHAR_FOR_REPLACE);
	}
	
	public String toSql(Object obj){
		return StringUtils.replaceFirst("'?'", SqlConstant.CHAR_FOR_REPLACE, StringUtils.filterSql(obj.toString()));
	}

	public List toValueList(Object obj) {
		List list=new LinkedList();
		list.add(StringUtils.filterSql(obj.toString()));
		return list;
	}
}
